package biz.k11i.gdd2011.util;

public class StopWatch {
    private long cumulativeMilliSeconds;

    private long startMilliSeconds;

    private boolean running;

    public void start() {
        if (!running) {
            startMilliSeconds = System.currentTimeMillis();
            running = true;
        }
    }

    public void stop() {
        if (running) {
            cumulativeMilliSeconds += System.currentTimeMillis()
                    - startMilliSeconds;
            running = false;
        }
    }

    public void reset() {
        running = false;
        cumulativeMilliSeconds = 0;
    }
    
    public long elapsedTime() {
        return cumulativeMilliSeconds;
    }
    
    public String elapsedSeconds() {
        return (cumulativeMilliSeconds / 1000.0) + " secs";
    }
}
